<template>
  <div class="statis-wrap">
    <div class="left-wrap">
      <common ref="common"></common>
      <overview ref="overview"></overview>
      <chart :chartHeight="chartHeight"></chart>
    </div>
    <div class="right-wrap">
      <wait></wait>
      <notice></notice>
      <trend></trend>
    </div>
  </div>
</template>

<script>
import chart from "./modules/chart_left.vue";
import common from "./modules/common_left.vue";
import overview from "./modules/overview_left.vue";
import notice from "./modules/notice_right.vue";
import trend from "./modules/trend_right.vue";
import wait from "./modules/wait_right.vue";
import bus from "@/bus/bus"
export default {
  name:"static",
  data(){
    return {
      chartHeight:400
    }
  },
  components:{
    common,overview,chart,notice,trend,wait
  },
  methods:{
    getWrapHeight(){
      this.$nextTick(() => {
        if(this.$refs.common&&this.$refs.overview){
          const comDom = this.$refs.common.$el.getBoundingClientRect();
          const overDom = this.$refs.overview.$el.getBoundingClientRect();
          this.chartHeight = this.calcHeight(comDom.height+overDom.height-40);
        }
      })
    }
  },
  mounted(){
    this.getWrapHeight(100)
    window.addEventListener('resize',(event) => {
      this.getWrapHeight()
    })
    bus.$on('updateOverView',() => {
      this.getWrapHeight()
    })
  }
}
</script>

<style lang="scss">
.statis-wrap{
  height: 100%;
  h5{
    line-height: 28px;
  }
  .left-wrap{
    float: left;
    width: 75%;
    border-right: 1px solid #ddd;
    &>div{
      padding: 10px;
      background: #fff;
      border-bottom: 1px solid #ddd;
      &:last-child{
        border: 0;
      }
      &:first-child{
        padding: 0 10px;
      }
    }
  }
  .right-wrap{
    overflow: hidden;
    height: 100%;
    &>div{
      height: 30%;
      border-bottom: 1px solid #ddd;
      padding: 10px;
      background: #fff;
      &:last-child{
        border: 0;
      }
      &:first-child{
        padding: 0 10px;
        height: 40%;
        overflow: auto;
      }
    }
  }
}
</style>